package com.jy.api.domain;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by hanxi on 2017/10/21.
 */
@Entity
@Data
@NoArgsConstructor
@Table(uniqueConstraints = @UniqueConstraint(name = "UK_STORE_PROFILE_STORE_ID", columnNames = {"storeId"}))
public class StoreProfile {
    @Id
    @Column(length = 50)
    private String id;
    @Column(nullable = false)
    private String storeId;
    @Embedded
    private StoreContact contact;
    @Embedded
    private StoreInfo info;
    @Embedded
    private SettlementCard card;

    @Column(nullable = false)
    private String businessLicenseImage;
    @Column(nullable = false)
    private String nicCardUpSideImage;
    @Column(nullable = false)
    private String nicCardDownSideImage;
    @Column(nullable = false)
    private String storeImage;
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private StoreProfileStatus status = StoreProfileStatus.SUBMITTED;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date addTime;
    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    private String bankCard;

    private String innerCard;

    private String barCard;

    private String bankCardSide;

    private String oneManagePlace;

    private String twoManagePlace;

    private String otherImageOne;

    private String otherImageTwo;

    @Embeddable
    @NoArgsConstructor
    @Data
    private static class StoreContact {
        @Column(nullable = false, name = "contact_name")
        private String name;
        @Column(nullable = false, name = "contact_nic_number")
        private String nicNumber;
        @Column(nullable = false, name = "contact_mobile")
        private String mobile;
        @Column(nullable = false, name = "contact_wechat_id")
        private String wechatId;
    }

    @Embeddable
    @NoArgsConstructor
    @Data
    private static class StoreInfo {
        @Column(nullable = false, name = "store_name")
        private String name;
        @Column(nullable = false, name = "store_abbr_name")
        private String abbrName;
        @Column(nullable = false)
        private String licenseNumber;
        @Column(nullable = false, name = "store_ad_name")
        private String adName;
        @Column(nullable = false, name = "store_addr")
        private String addr;
        @Column(nullable = false)
        private String email;
        @Column(nullable = false)
        private String customerServiceTele;
    }

    @Embeddable
    @NoArgsConstructor
    @Data
    private static class SettlementCard {
        @Column(nullable = false)
        private String accountHolder;
        @Column(nullable = false, name = "account_holder_nic_number")
        private String nicNumber;
        @Column(nullable = false, name = "account_holder_mobile")
        private String mobile;
        @Column(nullable = false)
        private String debitCardNumber;
        @Column(nullable = false)
        private String bankName;
        @Column(nullable = false, name = "bank_ad_name")
        private String adName;
        @Column(nullable = false)
        private String branchBankName;


    }
}
